import React, { lazy } from 'react';

const Home = lazy(() => import('../pages/Home'));
const HomeA = lazy(() => import('../pages/Home1'));
const HomeB = lazy(() => import('../pages/Home2'));
const Table = lazy(() => import('../pages/Table/Table'));
const Table1 = lazy(() => import('../pages/Table/Table1'));
const Table2 = lazy(() => import('../pages/Table/Table2'));
const Table3 = lazy(() => import('../pages/Table/Table3'));
const Fail = lazy(() => import('../pages/fail'));

const routes = [
  {
    path: '/',
    redirect: '/table',
    exact: true,
  },
  {
    path: '/table',
    component: Table,
    exact: false,
    children: [
      {
        path: '/table/table1',
        component: Table1,
        exact: true,
      },
      {
        path: '/table/table2',
        component: Table2,
        exact: true,
      },
      {
        path: '/table/table3',
        component: Table3,
        exact: true,
      },
      {
        path: '/table',
        redirect: '/table/table1',
        exact: true,
      },
    ],
  },
  {
    path: '/home',
    component: Home,
    exact: false,
    children: [
      {
        path: '/home/home1',
        component: HomeA,
        exact: true,
      },
      {
        path: '/home/home2',
        component: HomeB,
        exact: true,
      },
      {
        path: '/home',
        redirect: '/home/home1',
        exact: true,
      },
    ],
  },
  // 找不到路径的时候 进行匹配
  {
    path: '*',
    component: Fail,
    exact: false,
  },
];

export default routes;
